<?php

namespace app\api\logic;
use app\common\basics\Logic;
use app\service\TechnWeixinService;
use app\service\UserWeixinService;
use think\Db;
use app\Rtgm\sm\RtSm2;
use app\src\HeepayCustomer;

/**
 * 工作台统计
 * Class StatLogic
 * @package app\admin\logic\index
 */
class HuiLogic extends Logic
{
    //上传图片的私钥
    public static  $privateKey = 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD7puKqtYqXfmK2
dePzQmFh2HWiZGWefLRa3S/X4v9Y0iyYFr0x4hWgY3T7Zav4xIY6XBox24KhrsAE
Ay7Wikafn8r3FDUR2BL0iknB/K4sHQPkYiS56+yOZBs8+4MuAkSIzNety2W1913T
LDhadHBWQvJuJ60pR6tZSCm2sbuYalxKIGbS6FE8v5tFDMqPgnAlY57U4HW4rPLd
w5YVHpLg6kLC5Mf9+Wcnjv3qdmO2xpmxZ0iVIwL+i0+ITv3ILQEgo5D8G4bXZlmI
zXOR+lTBg3GPq/u7xQpdnp4UZGHQUX/CWOfELdBLbudTvllG/jV//R/iGpx0q/QJ
hiqQCBD7AgMBAAECggEASEIZH69VBj7yFTYwp+7Ni4zd6i0tyJ5CIz0TuceiTly7
FUiiNqqWTyF/u5fsE1hKuoMrulkvX0GQPRa04kF+GeOGIgAZZPBIMRNsLllhoaUL
Mw7DQOdvW0t/TrlhZ1qbVzSKUYrvv5oxxKsT21VH1F0Qw3R9EjdUCiTgZWcPWKnP
5ied84TWfEUOQyTnfZXXMr4P0ChtpYZKTjz6FzITo4DLmOnZunLuOSe+8BBJF23Y
xTMS0Doy49hGNt0ioPRtNA0qdx5WOjdcjK3/1Se9QlGTnWT+b5yRp+lnkxX8LMdm
ZIxfD3xWx8ta7vBiGNYdR0w4RdrNehjU8aMtJ1K+oQKBgQD/tHU4sj/MeAAyfHla
vB3iKR5ydNPoIscH0a+UMi+o7Fs8SE+tXUf/NrQHQiXSAkYZHsaXGR4e51OFaoct
r0DJvSWKViqGllqQGUk+c/CooXbHSvxpmUfP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vj1k0Ac1D3Hqkq3n253Nq/r9uzJGfU8y3uuwe
v3VnJslMc4bVoVVH041UAKVsvOwNDyTvqn/3/QBZCQ56XqxGeh6TgfUml48g1aWN
+QIDAQAB';

    //RSA2加密需要的合旭的appid
    public static $appid = 'hy2023091311111000628appid';

    //RSA2商户秘钥私钥
    public static  $private = 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzAMLNorSeuednQD1qWJ/cMP4OUzoQsBkpYhToEvafzs096gw/PLVbQKaXGUzDp3kjYcLxnnTKyqvl1NJ2SYFXN91E52yTbJ6Q1F7KZOgWsCWlcifMzd8rfEqXRxZn3KRLCWRFZIVjvwncc/LjM9UK+Tt792/zF6XvDPZgTCxCJ2rotIJqGJ9WPVymnawwOz/tLMbtayfgt9zzltg0xlQtTG/RbHo5MzwpdSNDniBn9Eq2z9ZKqiLNrHgCoCGOOGnTbHnS5/XtAxr/x6lI6RuRy2rQRbf+i653pGM4EuGB76NalwCE6JIfVegSlP4FzIWa1FhiwNRseB+VY1vd7rwvAgMBAAECggEAdzxvhtj15bFCAlYZUuib++mqodIwoIMdD6Lk+D4BiCwSLUblR45h49op3gadSssY90ecuqPpelgMrzjXxLFr9bQhsU9S1NUKvsCoL7uNmedV/GIRPux31xig+yoAM8kWq2EjKNIvxGSx5eZaiZuyMvAX/pixOsWq45TH3ReAd8N2hURvZfRTlTl+B/RzODYwbF9u0yr+bQsUzJ92GzS1h1BIkOf9CITWOPeaWgHr4yTxx1RpiFvNT1xCVYI7PxFwW4VOfQbFoaxvis1usT6QUlx5AHyutmlmGQ8UrvEBmBfE42vJZxSPno9bc0/UuybnpVG6pSxjePA0lmZ6sX2BqQKBgQD+pK5ub3P3ZA11//1qZrQAGh9li/7ItwFOBtt5oP5FcO5Pv/msMMU1owWv6Le8Kmq+i5zXM3o5qVG/Vq8j+G9cxkBJZ3XEHlkoJEyWzjgeEO2hdEZpi+wu5wq+1Us+vx9eHLUlJk97lrf4T1b85l9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sVxW8YdEPnGT4rME2inYlLVwn25157nycTtcuUptptcsDyyWMKvUdGKbgFyyMujIrewutwUVcYkoUdOCFCl4hGp3nlI15G1wYJLsYdrRVLOEtP6tpwYSjgtOhuWKGvBVydzbt+iy8LDB4T1NhaPPYqkq3IbVd8hOyDM47umWfBQKBgAO0ArDr0w/hYLzv1CEUKNge0GQZ9yY9OzGSp1tsKE8HdoleXYeIUmEXFAQLaTF1yScpm1DctRDEbGoUbJVAIxUo6k+ei5e1oCDq19z+Hq1+CZ4nQ/qe3sIiwfWCJCNvOreOWEFX+yVIT16YXlT9nnPeACg5WgPu6VRIHotzU4cRAoGBAL0BS+2yoFmGri09Iut2QdOreeaaOE75zYfHeUifYZBhhTDMdoOpGwsg2tudTNBiW5rwNT/Ir6qZJDtF2QQsbWi1+4/m+lje64CXZ1TCIad4U8A3CeNykpudFZhhRI0Rv2kiM7iPeNUn1b9xWPIu18vvK/9Wos+1t9CNcyTLBVftAoGANhG/+S36X5qiGJ9POJ97oXx7D+dmOsdy8HOIY7wCG9+kjXZRgzv9Gh44uRnZoNTlG5OKrCo9aDeJKCODgvY3aaG4e6p3+aCocrwuBTXnc5BxjiUsye6mos8YCoX5l4MXEAAx5ERSZSwdBMis+2eJUhSeqpqZr8xi407BnKjhF6s=
-----END PRIVATE KEY-----';

    //RSA提现商户私钥
    public static $tixian_RSA_hexu_siyao = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCkWdWhskZiYU/nwOYcCIPFI6NdUVkd6s+a6AfUU/ZruNx7H4ttutnNQbFD9AmbHcIKpLrEH5PE9jUNwdocatophnHhECopwnVrFDjlmloNcF3TmZYerqBS76xkmMGQv5eS7k/laYkYaNQ73JI4OcvbT4tbX2j5uk+BkCGox5tw/1OtQCo6DuttXwgbgMZSJD8G7JwwmlzavirasWwPUUkywoq8CrgzsieQ7nB9eFMBnhu5HpeZ9e/jV32aDBrWRSvvV/qDDmJyPn7fofvcMuRmZgJjzdx9t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24Vv1c6BXoBvjzZo0bLwXbF6RdPBqE+cCgYEA1SrVdTrR1SAhZNF+8JJokuvkspc0+mzOtNulG+WQodtADWhrqnu7na/7NZdkBTifStyQrh2R2R+cRjdr6cB/IzHe/hG4XOJO6fDgdoC0fdygqCW2Rc5DGY63GYn9CTT8kiD9axCwJsojL7gfU5Ia326qrn5ZpraXNsD23J8u4uk=';

    //RSA提现汇付宝公钥
    public static $tixian_RSA_Hui_gongyao ="-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzL82Eo3LYo9erunrm6GP
tM4qa0y9aLRLgMmPwpKjSq6ejzCVFgWxMo/NhIJDaVD3DaCykdrL4D5wkYc5GuTc
31XGJHky7unV64YDBbSArOF4/0ouyMwEQQi5ULyxHIM0H4i7vyCrU2YeQTqEbX8K
aMjOTHKuZ2u1chcG+zLGHuIMjrx9Qq2VKokscxWBvdJdzmHFgWiFg7ZSsZHyj0dO
3qqeXIQ2xnMYznJOHPp05Fm73KvczopRc2KP/6SUdJ37hWdSA2smyOj9E+DqOPMA
P1baZPQwDLtHnZT8JEq4WZFdHuRoGP/ebPow+NOJoBjOYwPwDbJYQpLmBSSigPmk
VQIDAQAB
-----END PUBLIC KEY-----";
    //rsa和rsa2 PHP版签名生成以及验证类
    //$content,$signature,$publicKey,$type,$content原文，$signature被验证的签名，$publicKey和$privateKey公私钥都是只有内容的一行字符串，$type为rsa，或者rsa2

    public static function sign($content,$privateKey,$type = 'rsa2'){

        if (is_array($content)){
            //将请求的参数进行排序
            ksort($content);//ksort()函数 根据参数的键进行升序排序
            reset($content);
            $signStr = '';
            foreach ($content as $key => $value) {
                if ($key == 'sign' || $value == '') continue;
                $signStr .= $key . '=' . $value . '&';
            }
            $signStr = substr($signStr, 0, -1);
            $content = $signStr;

        }
        if($type == "rsa"){
            openssl_sign($content,$signature,"-----BEGIN PRIVATE KEY-----\n".$privateKey."\n-----END PRIVATE KEY-----", OPENSSL_ALGO_SHA1);
        }elseif ($type == "rsa2") {
            openssl_sign($content,$signature,"-----BEGIN PRIVATE KEY-----\n".$privateKey."\n-----END PRIVATE KEY-----", OPENSSL_ALGO_SHA256);
        }else{
            throw new \Exception("Only support OPENSSL_ALGO_SHA1 or OPENSSL_ALGO_SHA256 algorithm signature!");
        }
        return base64_encode($signature);
    }

    /**
    正式证书加密
     **/
    public static function ssign($content,$privateKey,$type = 'rsa2'){

        if (is_array($content)){
            //将请求的参数进行排序
            ksort($content);//ksort()函数 根据参数的键进行升序排序
            reset($content);
            $signStr = '';
            foreach ($content as $key => $value) {
                if ($key == 'sign' || $value == '') continue;
                $signStr .= $key . '=' . $value . '&';
            }
            $signStr = substr($signStr, 0, -1);
            $content = $signStr;

        }

        if($type == "rsa"){
            openssl_sign($content,$signature,"-----BEGIN PRIVATE KEY-----\n".$privateKey."\n-----END PRIVATE KEY-----", OPENSSL_ALGO_SHA1);
        }elseif ($type == "rsa2") {
            openssl_sign($content,$signature,"-----BEGIN PRIVATE KEY-----\n".$privateKey."\n-----END PRIVATE KEY-----", OPENSSL_ALGO_SHA256);
        }else{
            throw new \Exception("Only support OPENSSL_ALGO_SHA1 or OPENSSL_ALGO_SHA256 algorithm signature!");
        }
        return base64_encode($signature);
    }

    public static function verify($content,$signature,$publicKey,$type = 'rsa2'){
        if($type == "rsa"){
            return openssl_verify($content,base64_decode($signature),"-----BEGIN PUBLIC KEY-----\n".$publicKey."\n-----END PUBLIC KEY-----", OPENSSL_ALGO_SHA1);
        }elseif ($type == "rsa2") {
            return openssl_verify($content,base64_decode($signature),"-----BEGIN PUBLIC KEY-----\n".$publicKey."\n-----END PUBLIC KEY-----", OPENSSL_ALGO_SHA256);
        }else{
            throw new \Exception("Only support OPENSSL_ALGO_SHA1 or OPENSSL_ALGO_SHA256 algorithm signature verify!");
        }
    }

    /**
    RSA解密字符串
    传入加密字串 $encrypted
     */
    public static function jiemi($data,$siyao = null){
        if (empty($siyao)){

            // 设置自己的私钥
            $private_key_str = self::$fenzhang_RSA_siyao;
        }else{
            $private_key_str = $siyao;
        }

        // 设置对方的公钥
        $partner_public_key_str =
            "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw6u9bHPvnJYOzY8gtFdy8EHBaz+HE4xo9AB9wnD5TGSR/V1qkOKS8Msz17peHX4cJOkiNj9eI0gMbXFpfKLGqj8znpMVIPLPCBoIsbeBLiedpd/OiHLCSTE8yHyw2s7qR+aXfN4sd3pWKG7v00KZd4CF/kKQgKQ1K8F001w8vCEawKI39VUYHMi9v/mR1nKOx3ARNjJfXYEJ0OIs9h/4G3CJy0YYEzpsMM3/Nmd/NXwUsb6qkN5+QXMNnqqzUWEprY2Zr9AcAo51OJ3ZjsWUXteTwRliTotcK59roDQBOvmMCcRlkOW/3xNGcngb90M3p2o0pVjyup+HzoF5DAjrewIDAQAB
-----END PUBLIC KEY-----";


        /* //分段解密方法
        //获取配置密钥 */

        $PRIVATEkey = $private_key_str;

        /* // 要解密的数据是    $data
        // 对加密数据进行处理（例如Base64解码） */

//        $data='';

        $encryptedData = base64_decode($data);
//        dump($encryptedData);die;
        // 定义每个分段的大小
        $chunkSize = 256; // 2048-bit key can decrypt 256 bytes

        // 分段解密
        $decryptedData = '';
        for ($i = 0; $i < strlen($encryptedData); $i += $chunkSize) {
            $chunk = substr($encryptedData, $i, $chunkSize);
            openssl_private_decrypt($chunk, $decryptedChunk, $PRIVATEkey);
            $decryptedData .= $decryptedChunk;
        }
//        // 输出解密后的原始数据
//        if (!empty($decryptedData)){
//            $return = explode('&',$decryptedData);
//        }
//        $tmp = [];
//        foreach ($return as  $value){
//            $str = explode('=',$value);
//            $tmp[$str[0]] = empty($str[1]) ? '':$str[1];
//        }
        return $decryptedData;
    }

    /**
    RAS解密字符串
     */
    public static function jiemi_n($data,$siyao = null){
        if (empty($siyao)){

            // 设置自己的私钥
            $private_key_str = self::$fenzhang_RSA_siyao;
        }else{
            $private_key_str = $siyao;
        }

        // 设置对方的公钥
        $partner_public_key_str =
        "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw6u9bHPvnJYOzY8gtFdy8EHBaz+HE4xo9AB9wnD5TGSR/V1qkOKS8Msz17peHX4cJOkiNj9eI0gMbXFpfKLGqj8znpMVIPLPCBoIsbeBLiedpd/OiHLCSTE8yHyw2s7qR+aXfN4sd3pWKG7v00KZd4CF/kKQgKQ1K8F001w8vCEawKI39VUYHMi9v/mR1nKOx3ARNjJfXYEJ0OIs9h/4G3CJy0YYEzpsMM3/Nmd/NXwUsb6qkN5+QXMNnqqzUWEprY2Zr9AcAo51OJ3ZjsWUXteTwRliTotcK59roDQBOvmMCcRlkOW/3xNGcngb90M3p2o0pVjyup+HzoF5DAjrewIDAQAB
-----END PUBLIC KEY-----";


        /* //分段解密方法
        //获取配置密钥 */

        $PRIVATEkey = $private_key_str;

        /* // 要解密的数据是    $data
        // 对加密数据进行处理（例如Base64解码） */

//        $data='';

        $encryptedData = base64_decode($data);
//        dump($encryptedData);die;
        // 定义每个分段的大小
        $chunkSize = 256; // 2048-bit key can decrypt 256 bytes

        // 分段解密
        $decryptedData = '';
        for ($i = 0; $i < strlen($encryptedData); $i += $chunkSize) {
            $chunk = substr($encryptedData, $i, $chunkSize);
            openssl_private_decrypt($chunk, $decryptedChunk, $PRIVATEkey);
            $decryptedData .= $decryptedChunk;
        }
        // 输出解密后的原始数据
        if (!empty($decryptedData)){
            $return = explode('&',$decryptedData);
        }
        $tmp = [];
        foreach ($return as  $value){
            $str = explode('=',$value);
            $tmp[$str[0]] = empty($str[1]) ? '':$str[1];
        }
        return $tmp;
    }

    public static function upload_bd($file,$pwd){

        $info = $file->move($pwd);
        dump($info);
        if(!empty($info))
        {
            $url = $pwd.'/'.str_replace('\\', '/', $info->getSaveName());
            $ImageSize=GetImageSize('.'.$url);
            return  $url;
        }else
        {
            return $file->getError();
        }

    }

    public static function uplode($file){

        $send = [
            'app_id'=>'hykj001',
            'method'=>'customer.media.upload',
            'version'=>'1.0',
            'charset'=>'utf-8',
            'format'=>'json',
            'sign_type'=>'RSA2',
            'timestamp'=>date('Y-m-d H:i:s'),
            'credential_type'=>'01',
        ];
        $image = $file;
        $fp = fopen($image,'rb+');
        $content = fread($fp,filesize($image));

        $send['file_sign'] = md5($content);
        $privateKey = self::$privateKey;
        $publicKey = self::$publicKey;
        $result = self::sign($send,$privateKey);

        $send['sign'] = $result;
        $send['file_content'] = new \CURLFile($file);
        $url = 'https://openapi.heepay.com/customer-api/customer.media.upload';
        $result = self::request_post($url,$send,'content-Type: multipart/form-data;');


        return $result;

    }
    public static function ruzhu($biz_content){
        $send['app_id'] = 'hy2023091311111000628appid';
        $send['method'] = 'customer.entry.apply';
        $send['version'] = '1.0';
        $send['charset'] = 'utf-8';
        $send['format'] = 'json';
        $send['timestamp'] = date('Y-m-d H:i:s');
        $send['notify_url'] = 'https://h5.hexukeji.com/api/v1/Hui/pay_back';
        $send['sign_type'] = 'RSA2';

        $send['biz_content'] = json_encode($biz_content,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        $privateKey = self::$private;
        $result = self::ssign($send,$privateKey);
        $send['biz_content'] = $biz_content;
        $send['sign'] = $result;
        $send = json_encode($send,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        $url = 'https://openapi.heepay.com/customer-api/gateway';
        $result = self::request_post($url,$send);
        return $result;
    }



    public static function company(){
        $biz_content = [
            //是否签约
            'if_sign'=>'1',
            //客户类型
            'customer_type'=>'1',
            //客户名称
            'customer_name'=>'太原合旭网络科技有限公司',
            //名字简称
            'customer_short_name'=>'太原合旭',
            //客服电话
            'customer_phone'=>'13100008431',
            //营业执照编码
            'licence_code'=>'91149900MA7XHL8Q3M',
            //有效期类型
            'licence_valid_type'=>'2',
            //生效时间
            'licence_valid_begin'=>'2022-08-02',
            //区划编码
            'licence_region_code'=>'140105',
            //地址
            'licence_address'=>'山西转型综合改革示范区学府产业园平阳路426号大和昌业29层2901室',
            //经营类目编码
            'business_category_code'=>'1000',
            //法人名称
            'legal_name'=>'吉晓彬',
            //身份证号
            'legal_id_card'=>'142430199109301637',
            //证件有效期类型
            'legal_id_card_valid_type'=>'1',
            //开始
            'legal_id_card_valid_begin'=>'2019-03-20',
            'legal_id_card_valid_end'=>'2039-03-20',
            'legal_mobile'=>'13100008431',
            'contact_name'=>'吉晓彬',
            'contact_id_card'=>'142430199109301637',
            'contact_id_card_valid_type'=>'1',
            'contact_id_card_valid_begin'=>'2019-03-20',
            'contact_id_card_valid_end'=>'2039-03-20',
            'contact_mobile'=>'13100008431',
            'contact_email'=>'jixiaobin@hexu2022.vip',
            'bank_account_type'=>'1',
            //结算银行账户名称
            'bank_account_name'=>'太原合旭网络科技有限公司',
            //卡号
            'bank_card_no'=>'14050182580800001279',
            //开户行名称
            'bank_name'=>'建设银行',
            //开户行所属区划编码
            'bank_region_code'=>'140105',
            //营业执照图片路径
            'licence_img'=>'/public/01/20230915/fde3ad262ae16409aab8ae20c656900f.jpg',
            //公司大楼图片路径
            'company_build_img'=>'/public/01/20230915/e4bfccc6af1cca30bc900f5744b49708.jpg',
            //公司前台图片路径
            'company_front_img'=>'/public/01/20230915/63c2761d4273a6662dbb91d7d35abd8e.jpg',
            //店内场景照图片路径
            'shop_env_img'=>'/public/01/20230915/3c960bc02fbf46fb9b562987090dfaa0.jpg',
            //开户许可证图片路径
            'reg_certificate_img'=>'/public/01/20230915/f62cc8150404e7d5b5be759a46bd3d40.jpg',
            //法人身份证人像面图片路径
            'legal_id_card_front_img'=>'/public/01/20230915/a72dd36a001b43d75379d003c6090066.jpg',
            //法人身份证国徽面图片路径
            'legal_id_card_back_img'=>'/public/01/20230915/c366c5f4b3a0685f947b261e6687253e.jpg',
            //业务员身份证人像面图片路径
            'contact_id_card_front_img'=>'/public/01/20230915/a72dd36a001b43d75379d003c6090066.jpg',
            //业务员身份证国徽面图片路径
            'contact_id_card_back_img'=>'/public/01/20230915/c366c5f4b3a0685f947b261e6687253e.jpg',
        ];

        $send = [
            "app_id"=>self::$appid,
            "method"=>"customer.entry.apply",
            "version"=>"1.0",
            "charset"=>"utf-8",
            "format"=>"json",
            "timestamp"=>date('Y-m-d H:i:s',time()),
            "notify_url"=>"https://h5.hexukeji.com/api/Hui/pay_back",
            "sign_type"=>"RSA2",
        ];

        $send['biz_content'] = json_encode($biz_content,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

        $result = self::ssign($send,self::$private);
        $send['biz_content'] = $biz_content;
        $send['sign'] = $result;
        $send = json_encode($send,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        dump($send);
        $url = 'https://openapi.heepay.com/customer-api/gateway';
        $result = self::request_post($url,$send);
        return $result;



    }

    public static function fix_shop(){
        $biz_content = [
            //是否签约
            'if_sign'=>'1',
            //客户类型
            'customer_type'=>'1',
            //客户名称
            'customer_name'=>'太原合旭网络科技有限公司',
            //名字简称
            'customer_short_name'=>'太原合旭',
            //客服电话
            'customer_phone'=>'13100008431',
            //营业执照编码
            'licence_code'=>'91149900MA7XHL8Q3M',
            //有效期类型
            'licence_valid_type'=>'2',
            //生效时间
            'licence_valid_begin'=>'2022-08-02',
            //区划编码
            'licence_region_code'=>'140105',
            //地址
            'licence_address'=>'山西转型综合改革示范区学府产业园平阳路426号大和昌业29层2901室',
            //经营类目编码
            'business_category_code'=>'1000',
            //法人名称
            'legal_name'=>'吉晓彬',
            //身份证号
            'legal_id_card'=>'142430199109301637',
            //证件有效期类型
            'legal_id_card_valid_type'=>'1',
            //开始
            'legal_id_card_valid_begin'=>'2019-03-20',
            'legal_id_card_valid_end'=>'2039-03-20',
            'legal_mobile'=>'13100008431',
            'contact_name'=>'吉晓彬',
            'contact_id_card'=>'142430199109301637',
            'contact_id_card_valid_type'=>'1',
            'contact_id_card_valid_begin'=>'2019-03-20',
            'contact_id_card_valid_end'=>'2039-03-20',
            'contact_mobile'=>'13100008431',
            'contact_email'=>'jixiaobin@hexu2022.vip',
            'bank_account_type'=>'1',
            //结算银行账户名称
            'bank_account_name'=>'太原合旭网络科技有限公司',
            //卡号
            'bank_card_no'=>'14050182580800001279',
            //开户行名称
            'bank_name'=>'建设银行',
            //开户行所属区划编码
            'bank_region_code'=>'140105',
            //营业执照图片路径
            'licence_img'=>'/public/01/20230915/fde3ad262ae16409aab8ae20c656900f.jpg',
            //公司大楼图片路径
            'company_build_img'=>'/public/01/20230915/e4bfccc6af1cca30bc900f5744b49708.jpg',
            //公司前台图片路径
            'company_front_img'=>'/public/01/20230915/63c2761d4273a6662dbb91d7d35abd8e.jpg',
            //店内场景照图片路径
            'shop_env_img'=>'/public/01/20230915/3c960bc02fbf46fb9b562987090dfaa0.jpg',
            //开户许可证图片路径
            'reg_certificate_img'=>'/public/01/20230915/f62cc8150404e7d5b5be759a46bd3d40.jpg',
            //法人身份证人像面图片路径
            'legal_id_card_front_img'=>'/public/01/20230915/a72dd36a001b43d75379d003c6090066.jpg',
            //法人身份证国徽面图片路径
            'legal_id_card_back_img'=>'/public/01/20230915/c366c5f4b3a0685f947b261e6687253e.jpg',
            //业务员身份证人像面图片路径
            'contact_id_card_front_img'=>'/public/01/20230915/a72dd36a001b43d75379d003c6090066.jpg',
            //业务员身份证国徽面图片路径
            'contact_id_card_back_img'=>'/public/01/20230915/c366c5f4b3a0685f947b261e6687253e.jpg',
        ];

        $send = [
            "app_id"=>self::$appid,
            "method"=>"customer.entry.apply",
            "version"=>"1.0",
            "charset"=>"utf-8",
            "format"=>"json",
            "timestamp"=>date('Y-m-d H:i:s',time()),
            "notify_url"=>"https://h5.hexukeji.com/api/Hui/pay_back",
            "sign_type"=>"RSA2",
        ];

    }

    public static function check_add($mobile = '13100008431'){
        $info = Db::name('apply_shop')->where('manage_mobile',$mobile)->find();
        if (!empty($info)){
            $data = [
                'appid'=>self::$appid,
                'method'=>'customer.entry.query',
                'format'=>'json',
                'charset'=>'utf-8',
                'sign_type'=>'RSA2',
                'timestamp'=>date('Y-m-d H:i:s',time()),
                'version'=>'1.0',
                'notify_url'=>'https://h5.hexukeji.com/api/v1/Hui/pay_back',
                'biz_content'=>['apply_no'=>$info['apply_no']]
            ];
            $sign = self::sign(json_encode($data,256),self::$private);
            $data['sign'] = $sign;
            $url = 'https://openapi.heepay.com/customer-api/gateway/';
            $datas = json_encode($data,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            $result = self::httpPost($url,$datas);
            return $result;
        }

    }


    public static function pay($info){
        $url = 'https://pay.heepay.com/Payment/Index.aspx';


        $sign_arr = [
            'version'=>'1',
            'agent_id'=>'2154762',
            'agent_bill_id'=>$info['agent_bill_id'],
            'agent_bill_time'=>date('YmdHis',time()),
            'pay_type'=>'30',
            'pay_amt'=>$info['pay_amt'],//单位元
            'notify_url'=>$info['notify_url'],
            'return_url'=>$info['return_url'],
            'user_ip'=>implode('_',explode('.',self::getIP())),
            'key'=>'3431F853A7CB4802A51C2D9C',
            'ref_agent_id'=>'2169937',
        ];

        $sign_str = '';
        foreach ($sign_arr as $key => $value){
            $sign_str .= $key.'='.$value.'&';
        }

        $sign_str = substr($sign_str,0,-1);
        $sign = md5($sign_str);
        $data = [
            'version'=>'1',
            'is_phone'=>'1',
            'is_frame'=>'1',
            'pay_type'=>'30',
            //商户编号
            'agent_id'=>'2154762',
            //子商户编号
            'ref_agent_id'=>'2169937',
            //订单号
            'agent_bill_id'=>$info['agent_bill_id'],
            'agent_bill_time'=>date('YmdHis',time()),
            'pay_amt'=>'101',
            'notify_url'=>$info['notify_url'],
            'return_url'=>$info['return_url'],
            'user_ip' => implode('_',explode('.',self::getIP())),
            'goods_name'=>urlencode($info['goods_name']),
            'goods_num'=>$info['goods_num'],
            'remark'=>'',
            'meta_option'=> base64_encode(json_encode(['s'=>'WAP','n'=>'摩小妹','id'=>'https://h5.hexukeji.com/h5/pages/index/index'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)),
//            'timestamp'=>time()*1000,
            'expire_time'=>'5',
            'sign_type'=>'MD5',
            'sign'=>$sign
        ];

        $data = json_encode($data);
        $data = iconv("UTF-8","GB2312",$data);
        $data = json_decode($data,true);

//        字符串转码
//        iconv("GB2312","UTF-8",$str);
//        $result = self::request_post($url,$data);
        $url .= '?';

        foreach ($data as $key => $value){
            $url .= $key.'='.$value.'&';
        }
        $urls = explode('?',$url);
//        $urls[1] = urlencode($urls[1]);
        $url = implode('?',$urls);
        $url = substr($url,0,-1);

        return $url;
//        $result = self::request_get($url);
//        return $result;
   }


   public static function pay_backt($id,$no){
        $data = [
            'version'=>'1',
            'agent_id'=>$id,
            'agent_bill_id'=>$no,
            'agent_bill_time'=>date('YmdHis',time()),
            'return_mode'=>'1',
            'key'=>'3431F853A7CB4802A51C2D9C',
        ];
        $sign_str = '';
        foreach ($data as $key => $value){
           $sign_str .= $key.'='.$value.'&';
        }
       $sign_str = substr($sign_str,0,-1);

        unset($data['key']);
        $data['remark'] = '';
        $sign = md5($sign_str);
        $data['sign'] = $sign;

        $url = 'https://query.heepay.com/Payment/Query.aspx';
        $url .= '?';

        foreach ($data as $key => $value){
           $url .= $key.'='.$value.'&';
        }
        $url = substr($url,0,-1);
        $return = self::request_get($url);
//        $return = 'agent_id=2154762|agent_bill_id=202309161555241|jnet_bill_no=H2309169876205A9|pay_type=30|result=0|pay_amt=0.00|pay_message=|remark=|sign=44baa23d6ba742a5166c91e0a45f0950|pay_user=oE2GLs-UbOVQXCfxpF8fGFRQoyBI|third_bill_no=40823091698762056557|bank_card_type=-1|bank_card_owner_type=0|trade_bill_no=|detail_error_code=|detail_error_message=|ref_agent_id=2169937';

        $return = explode('|',$return);
        $tmp = [];
        foreach ($return as  $value){
            $str = explode('=',$value);
            $tmp[$str[0]] = empty($str[1]) ? '':$str[1];
        }
        return $tmp;

   }

   public static function return_order_no($info){
        $data = $info['encrypt_data'];
//        $data = self::verify($data,,self::$public,'rsa');
   }

   /**
    * 分账
    **/
    public static function deal_money($sign){

        $insert = $sign;
        $insert['add_time'] = time();
        $have = Db::name('fenzhang_list')->where('batch_no',$insert['batch_no'])->find();
        if (empty($have)){
            Db::name('fenzhang_list')->insert($insert);
        }
        $sign_str = '';
        foreach ($sign as $key => $value){
            $sign_str .= $key.'='.$value.'&';
        }
        $sign_str = substr($sign_str,0,-1);

        //组成参数
        $data = [
            'agent_id'=>'2154762',
            'encrypt_data'=>JiamiLogic::RSA_jiami($sign_str,1),
            'sign'=>JiamiLogic::RSA_jiami($sign_str,2),
        ];
        //拼接地址
        $url = 'https://Pay.Heepay.com/API/Allot/tradesubmit.aspx?';
        $turl = $url;
        $url .= '?';
        $tmp = '';
        foreach ($data as $key => $value){
            $tmp .= $key.'='.$value.'&';
        }
        $tmp = substr($tmp,0,-1);
        $url .= urlencode($tmp);

        $result = JiamiLogic::use_filegetcontent($data,$turl);
//        $result = self::request_get($url);
        return $result;


    }

    /**
    提现到银行卡
     */
    public static function take_money(){
        // 设置自己的私钥
        $siyao = self::$tixian_RSA_hexu_siyao;

        // 设置对方的公钥
        $gongyao = self::$tixian_RSA_Hui_gongyao;

        $data = [
            'version'=>'1.0',
            //商户号
            'agent_id'=>'2154762',

            'out_trade_no'=>'tx00002',

            //子商户号
            'sub_account_id'=>'2170550',
            'cash_fen'=>'500',
            'note'=>'提现',
        ];
        $data = json_encode($data,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        $sign = self::ssign($data,$siyao);
        $send['body'] = $data;
        $send['sign'] = $sign;
        $deal_send = json_encode($send,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

        $businessContext = JiamiLogic::RSA_jiami($deal_send,$gongyao,'1');
        $finale = json_encode([
            'agentid'=>'2154762',
            'businessContext'=>$businessContext,
        ]);

        $url = 'https://www.heepay.com/API/Agent/AgentSubCash.aspx';
        $result = self::request_post($url,$finale);
        dump($result);
        $result = json_decode($result,1);
        if (!empty($result['businessContext'])){
            $result = self::jiemi($result['businessContext'],"-----BEGIN PRIVATE KEY-----\n".$siyao."\n-----END PRIVATE KEY-----");
            return json_decode($result,1);

        }else{
            return $result;
        }
    }

    /**
    提现申请查询
     */
    public static function check_take(){
        // 设置自己的私钥
        $siyao = self::$tixian_RSA_hexu_siyao;

        // 设置对方的公钥
        $gongyao = self::$tixian_RSA_Hui_gongyao;

        $data = [
            'version'=>'1.0',
            'agent_id'=>'2154762',
            'out_trade_no'=>'tx00001',
        ];
        $data = json_encode($data,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        $sign = self::ssign($data,$siyao);

        $send['body'] = $data;
        $send['sign'] = $sign;
        $deal_send = json_encode($send,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

        $businessContext = JiamiLogic::RSA_jiami($deal_send,$gongyao,'1');
        $finale = json_encode([
            'agentid'=>'2154762',
            'businessContext'=>$businessContext,
        ]);

        $url = 'https://www.heepay.com/API/Agent/AgentSubCashQuery.aspx';
        $result = self::request_post($url,$finale);
        $result = json_decode($result,1);
        if (!empty($result['businessContext'])){
            $result = self::jiemi($result['businessContext'],"-----BEGIN PRIVATE KEY-----\n".$siyao."\n-----END PRIVATE KEY-----");
            return json_decode($result,1);
        }else{
            return $result;
        }
    }

   public static function request_get($url,$type=1){
       $curl = curl_init();
       curl_setopt($curl,CURLOPT_TIMEOUT,5000);
       curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
       curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
       curl_setopt($curl,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
       curl_setopt($curl,CURLOPT_URL,$url);

//       curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/4");
       curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
       if($type == 1){
           curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
       }
       $res = curl_exec($curl);
       if($res){
           curl_close($curl);
           return $res;
       }else {
           $error = curl_errno($curl);
           curl_close($curl);
           return $error;
       }
   }

    public static function  request_post($url = '', $param = '',$header = 'Content-Type: application/json') {
        if (empty($url) || empty($param)) {
            return '数据不全';
        }

        $headers = array($header);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

        curl_setopt($ch, CURLOPT_POST, TRUE);   //is it optional?
        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
        $data = curl_exec($ch);
//        var_dump(curl_error($ch));
        curl_close($ch);
        return $data;
    }
    // 模拟提交数据函数
    public static function httpPost($url,$data){
        $curl = curl_init(); // 启动一个CURL会话
        $header = array('Content-Type: application/json');
        curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
        curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
        curl_setopt($curl, CURLOPT_POSTFIELDS,  $data); // Post提交的数据包
        curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
        curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8");

        curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
        $result = curl_exec($curl); // 执行操作
        if (curl_errno($curl)) {
            return 'Error POST'.curl_error($curl);
        }
        curl_close($curl); // 关键CURL会话
        return $result; // 返回数据
    }

    public static function fox_post($url,$data){
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => '',
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POSTFIELDS => $data,
            CURLOPT_HTTPHEADER => array(
                'User-Agent: Apifox/1.0.0 (https://apifox.com)',
                'Content-Type: multipart/form-data',
                'Accept: */*',
                'Host: openapi.heepay.com',
                'Connection: keep-alive'
            ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        return $response;
    }

    /**
     * php获取用户真实 IP
     * 注意这种方式只适用于浏览器访问时
     */
    public static function getIP()
    {
        if (isset($_SERVER)){
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $realip = $_SERVER["HTTP_CLIENT_IP"];
            } else {
                $realip = $_SERVER["REMOTE_ADDR"];
            }
        } else {
            if (getenv("HTTP_X_FORWARDED_FOR")){
                $realip = getenv("HTTP_X_FORWARDED_FOR");
            } else if (getenv("HTTP_CLIENT_IP")) {
                $realip = getenv("HTTP_CLIENT_IP");
            } else {
                $realip = getenv("REMOTE_ADDR");
            }
        }
        return $realip;
    }
}